<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="auth" uri="http://www.jiyinit.com/authTag"%>

<div class="right-container">
    <div class="container-select text-left">
        <div class="search-input">
            <span>功能ID：</span>
            <input id="funId" name="funId" type="text">
        </div>
        <div class="search-input">
            <span>功能名称：</span>
            <input id="funName" name="funName" type="text">
        </div>
        <auth:auth authUrl="orgFun/findByPage">
            <button id="searchBtn" class="btn btn-primary" type="button">
                <i class="fa fa-search"></i> 查询
            </button>
        </auth:auth>
    </div>
    <div class="manage-button text-left">

        <auth:auth authUrl="orgFun/toUpdate">
            <button id="modifyBtn" class="btn btn-primary" type="button">
                <i class="fa fa-pencil"></i> 修改
            </button>
        </auth:auth>

    </div>
    <div class="row">
        <div class="col-xs-12">
            <table id="grid-table"></table>
            <div id="grid-pager"></div>
        </div>
    </div>
</div>

<!-- page specific plugin scripts -->
<script src="${basePath}/plugins/jqGrid/jquery.jqGrid.min.js${VERSION}"></script>
<script src="${basePath}/plugins/jqGrid/grid.locale-cn.js${VERSION}"></script>

<!-- inline scripts related to this page -->
<script type="text/javascript">
    var pageii = null;
    jQuery(function ($) {
        CommonUtils.grid({
            url: "${basePath}/orgFun/findByPage",
            colNames: ['功能ID','功能名称', '功能排序', '功能类型'],
            colModel: [
                {name: 'funId', index: 'funId', key: true, width: 20, sorttype: "int"},
                {name: 'funName', index: 'funName', width: 50},
                {name: 'funOrderBy', index: 'funOrderBy', width: 80},
                {name: 'funType', index: 'funType', width: 20,formatter:showType},
            ]
        });

        $("#searchBtn").click(function () {
            query();
        });

        function query() {
            var queryData = {
                "funId": $.trim($('#funId').val()),
                "funName": $.trim($('#funName').val())
            };
            $("#grid-table").jqGrid("setGridParam", {
                postData: queryData
            }
            ).trigger("reloadGrid", [{page: 1}]);
        };

        $("#modifyBtn").click("click", function () {
                   pageii = layer.open({
                title: "修改功能",
                type: 2,
                area: ["600px", "500px"],
                content: '${basePath}/orgFun/toUpdate'
            });

        });

        function showType(value, row, index){
            if(value == "1"){
                return "默认";
            }else if(value == "2"){
                return "普通";
            }else if(value == "3"){
                return "定制"
            }else {
                return ""
            }
        }
    });
</script>
